package com.doitedu.mr.day06;

import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Reducer;

import java.io.IOException;

/**
 * @Date 2021/12/7
 * @Created by HANGGE
 * @Description TODO
 * 对数据预聚合
 */
public class MyCombiner extends Reducer<Text, IntWritable , Text,IntWritable> {
    IntWritable v
         = new IntWritable();
    @Override
    protected void reduce(Text key, Iterable<IntWritable> values, Context context) throws IOException, InterruptedException {
        int cnt = 0 ;
        for (IntWritable value : values) {
            cnt++ ;
        }
        v.set(cnt);
        context.write(key , v);


    }
}
